import { createRouter, createWebHistory } from 'vue-router'
import { baseRoutes } from '@/core/router/routes'

// 动态加载子项目的路由配置
const routeModules = import.meta.glob('@/routes/*.ts', { eager: true })
const childRoutes = Object.values(routeModules)
  .map((module: any) => module.default)
  .flat()

// 合并基础项目和子项目的路由配置
const routes = [...childRoutes, ...baseRoutes]
// 创建路由实例
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes,
})

export default router
